﻿using UnityEngine;
using System.Collections;

public class AppleFactory : MonoBehaviour {

    public static AppleFactory _instance;
    //获取苹果预制物
    public GameObject applePrefab;
    ////获取当前场景中的苹果
    private GameObject _apple;

    void Awake()
    {
        _instance = this;
    }
    private void Create()
    {
        if (_apple!=null)
        {
            GameObject.Destroy(_apple);
        }
        _apple = GameObject.Instantiate(applePrefab);
        _apple.transform.position = new Vector3(Random.Range(-14, 14), Random.Range(1, 29), -0.5f);
    }


	// Use this for initialization
	void Start () {
        Create();
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
